package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.ysd.entity.GuanLiYuan;
import com.ysd.util.DBManager;

public class GuanLiYuanimpl {
	public GuanLiYuan getGuanLiYuanUsername(String username) {
		GuanLiYuan guanliyuan=null;
		Connection conn=DBManager.getConnection();
		Statement st=null;
		ResultSet rs=null;
		try {
			st=conn.createStatement();
			rs=st.executeQuery("SELECT *FROM guanliyuan WHERE username='"+username+"'");
			while(rs.next()) {
				int id=rs.getInt(1);
				String uname=rs.getString(2);
				String password=rs.getString(3);
				guanliyuan=new GuanLiYuan(id, uname, password);
			}
			return guanliyuan;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
